#ifndef __SERVER_SESSION_H__
#define __SERVER_SESSION_H__

#pragma once

#include <NetworkObject.h>

class GameServer;

class ServerSession : public NetworkObject
{
	friend class GameServer;

public:
	ServerSession();
	~ServerSession();

	virtual VOID			Init();
	virtual VOID			Release();
	virtual VOID			Update();

	virtual VOID			OnAccept( DWORD dwNetworkIndex );
	virtual VOID			OnDisconnect();
	virtual VOID			OnConnect( BOOL bSuccess, DWORD dwNetworkIndex );
	virtual VOID			OnRecv( BYTE *pMsg, WORD wSize ) { __UNUSED(pMsg); __UNUSED(wSize); }
	virtual VOID			OnLogString( char *pszLog );

	virtual eSERVER_TYPE	GetServerType() { return UNKNOWN_SERVER;	}

	DWORD					GetSessionIndex() { return m_dwSessionIndex; }
	VOID					SetSessionIndex( DWORD dwIdx ) { m_dwSessionIndex = dwIdx; }

	VOID					SendServerType();

	VOID					SetAddr( char *pszIP, WORD wPort );
	VOID					TryToConnect();

	inline std::string&		GetConnectIP() { return m_strConnectIP; }
	inline WORD				GetConnectPort() { return m_wConnectPort; }
	inline BOOL				IsConnected() { return m_bConnection; }
	inline VOID				SetForConnect( BOOL bForConnect ) { m_bForConnect = bForConnect; }
	inline BOOL				IsForConnect() { return m_bForConnect; }

private:
	DWORD					m_dwSessionIndex;
	std::string				m_strConnectIP;
	WORD					m_wConnectPort;
	BOOL					m_bForConnect;
	DWORD					m_dwLastHeartbeatTick;
	DWORD					m_bConnection;
};


#endif // __SERVER_SESSION_H__